<!-- TrainSelectPost.html -->
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
     <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>选择实习岗位</title>
	<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
</head>
<body>
    <div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
	<div class="base_navigation_bar base_style_color base_navigation_item_bar">
        <a class="base_left_item" href="#" onclick="backClick()">
            <img class="base_back_icon" src="../../image/icon_jiantou.png" alt="">
        </a>
        <span>选择实习岗位</span>
        <a class="base_right_item base_hide_item">
        </a>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript">
    var filepath = 'fs://postJson.json'
    apiready = function(){
        loadPostList();
        
    }
    function loadPostList(){
        var pageParam = api.pageParam;
        var cid = pageParam.cid;
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '加载岗位数据中...',
            text: '请稍候...',
            modal: false
        });
        cfnetppPOST(urlPostlist,
            {
                uid : $api.getStorage('cfnetppuid'),
                cid : cid
            },
            true,
            function(data, status){
                api.hideProgress();
//                alert (JSON.stringify(data));
                if (status == 'success') {
                    if (data.status == 1) {
                   
                        var worklist = data.json;
                        if (worklist.constructor == Array && worklist.length > 0) {
                            var workArr = new Array();
                            for (var i = 0; i < worklist.length; i++) {
                                var workData = worklist[i];
                                var work = {
                                    id : workData.id,
                                    city : workData.work_name
                                };
                                workArr.push(work);
                            }
                            var workObjc = {
                                'citys' : workArr
                            };
                            writeData(filepath, JSON.stringify(workObjc), function(ret, err){
                                if (ret.status) {
                                    setupPostList();
                                }else{
                                    api.toast({
                                        msg: '暂无该企业岗位信息'
                                    });
                                }
                            });
                        }
                    }else{
                        api.toast({
                            msg: '暂无该企业岗位信息'
                        });
                    }
                }else{
                    api.toast({
                        msg: '加载数据失败'
                    });
                }
            });
    }
    function setupPostList(){
        var y = $('.base_navigation_bar').height() + $('#BarAppearance').height();
        var h = api.winHeight - y;
        var UICityList = api.require('UICityList');
        UICityList.open({
            rect: {
                x: 0,
                y: y,
                w: api.frameWidth,
                h: h
            },
            resource: filepath,
            styles: {
                searchBar: {
                    bgColor: '#18b4ed',
                    cancelColor: '#fff'
                },
                location: {
                    color: '#696969',
                    size: 12
                },
                sectionTitle: {
                    bgColor: '#f0f0f0', 
                    color: '#696969',
                    size: 12
                },
                item: {
                    bgColor: '#fff',
                    activeBgColor: '#696969',
                    color: '#000',
                    size: 14,
                    height: 40
                },
                indicator: {
                    bgColor: '#fff',
                    color: '#696969'
                }
            },
            fixedOn: api.frameName,
            placeholder: '输入岗位名或首字母查询',
            hotTitle: ''
        }, function( ret, err ) {
            if( ret.eventType == 'selected'){
                api.sendEvent({
                    name: 'selectPostNotifi',
                    extra: {
                        id: ret.cityInfo.id, 
                        postname: ret.cityInfo.city
                    }
                });
                backClick();
            }else{
//              alert( JSON.stringify( err ) );
            }
        });
    }
    function backClick(){
        api.closeWin();
    }
</script>
</html>